package com.zmj.controller;

import com.alibaba.fastjson.JSON;
import com.zmj.service.IUserInfoService;
import com.zmj.service.impl.UserInfoServiceImpl;
import com.zmj.utils.Message;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/del")
public class DelInfoServlet extends HttpServlet {
    IUserInfoService userInfoService=new UserInfoServiceImpl();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String s=req.getParameter("uid");
        long uid=Long.parseLong(s);
        boolean flg=userInfoService.delInfo(uid);
        Message message =new Message();
        if (flg){
            message.setMes("del success");
            message.setCode(1);
        }else {
            message.setCode(0);
            message.setMes("del fail");
        }
        resp.getWriter().print(JSON.toJSONString(message));
    }
}
